#ifndef BEAR_FACTORY_H_
#define BEAR_FACTORY_H_

#include <QString>
#include <QMap>

#include "BBFactory.h"

class Bear;

class BearFactory
{
public:
	static BearFactory* instance();

	void registerFactory( QString className, BBFactory* factory )
	{
		m_factories[className] = factory;
	}

	Bear* createBear( QString& className )
	{
		return m_factories[className]->instance();
	}

	bool exist( QString& className )
	{
		return m_factories.contains( className );
	}

private:
	BearFactory()
	{
		//DOES NOTHING
	}
	~BearFactory()
	{
		//DOES NOTHING
	}

	static BearFactory* m_instance;
	QMap<QString, BBFactory*> m_factories;
};

/*
#define BUILD_FACTORY( ClassName ) \
	class ClassName##Factory : BBFactory { \
	public: \
		virtual Bear* instance { return new ClassName }; \
	};
*/

#define REGISTER_FACTORY( className ) \
	BearFactory::instance()->registerFactory( #className, new className##Factory );

#define CREATE_FACTORY( className ) \
	className##Factory factory = className##Factory(); 

#endif